
import java.io.IOException;
import java.io.ObjectInputStream;
import java.net.Socket;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.logging.Level;
import java.util.logging.Logger;


public class StorageServerT implements Runnable{

        Socket client;
        ConcurrentLinkedQueue<ReplyTo> orders;
        ObjectInputStream in;


    public StorageServerT(Socket client, ConcurrentLinkedQueue<ReplyTo> orders) throws IOException {
        this.client = client;
        this.orders = orders;
        this.in= new ObjectInputStream(client.getInputStream());
    }



    public void run(){
        try {
            System.out.println("bf object read");
            Request r = (Request) in.readObject();
            System.out.println("af object read");

            //Cria ReplayTo
            ReplyTo rt = new ReplyTo(r, client);
            
            orders.add(rt);
            System.out.println(orders.size());            
            in.close();
            
        } catch (IOException ex) {
            Logger.getLogger(StorageServerT.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(StorageServerT.class.getName()).log(Level.SEVERE, null, ex);
        }

    }
}
